package com.example.backend.service;

import com.example.backend.entity.Score;
import com.example.backend.mapper.ScoreMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

@Service
public class ScoreService {

    @Autowired
    private ScoreMapper scoreMapper;

    public int addScore(Score score) {
        return scoreMapper.addScore(score);
    }

    public int updateScore(Score score) {
        return scoreMapper.updateScore(score);
    }

    public ArrayList<Score> selectScoreByNum(String dingdan_num) {
        return scoreMapper.selectScoreByNum(dingdan_num);
    }

    public ArrayList<Score> selectAll() {
        return scoreMapper.selectAll();
    }

    /**
     * 删除评分
     * 测试软件返回null
     * @param dingdan_num
     * @return
     */
    public Integer deleteScoreByNum(String dingdan_num) {
        if(scoreMapper.selectScoreByNum(dingdan_num) == null){
            return -1;
        }
      return scoreMapper.deleteScore(dingdan_num);
    }

}
